package put.cs.two.to.tsp.models;

public class Edge {
    private final Point from;

    private final Point to;

    public Edge(Point from, Point to) {
        this.from = from;
        this.to = to;
    }

    public Point getAnotherPoint(Point point) {
        return (point.equals(from)) ? to : from;
    }

    public int getLength() {
        return NodeSet.getDistance(from, to);
    }

    public Point getFromPoint() {
        return from;
    }

    public Point getToPoint() {
        return to;
    }

    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof Edge)) {
            return false;
        }
        Edge toCompare = (Edge) obj;
        return (from == toCompare.from) && (to == toCompare.to);
    }

    @Override
    public String toString() {
        return from + " ===> " + to;
    }
}
